package tech.wetech.admin3.sys.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tech.wetech.admin3.sys.model.AooToken;
import tech.wetech.admin3.sys.repository.AooTokenRepository;

import java.time.LocalDateTime;

@Service
public class AooTokenService {
  private AooTokenRepository aooTokenRepository;

//  @Autowired
  public AooTokenService(AooTokenRepository aooTokenRepository){this.aooTokenRepository=aooTokenRepository;}

  @Transactional
  public AooToken saveAooToken(String token){
    LocalDateTime expireTime = LocalDateTime.now().plusHours(24);
    AooToken aooToken = new AooToken();

    aooToken.setToken(token);
    aooToken.setExpireTime(expireTime);

    return aooTokenRepository.save(aooToken);
  }
}
